<template>
  <el-dialog
    title="物流信息"
    :visible.sync="locationDialogVisible"
    width="50%">

    <!-- 内容 -->
    <Order-time-line :locationList="locationList"></Order-time-line>

    <!-- 按钮 -->
    <span slot="footer">
      <el-button @click="locationDialogVisible = false">取 消</el-button>
      <el-button type="primary" @click="locationDialogVisible = false">确 定</el-button>
    </span>

  </el-dialog>
</template>

<script>
// 请求
  import { locationData } from '@/network/orderRequest';

// 组件
  import OrderTimeLine from '@/views/Main/order/orderCompent/OrderTimeLine';

export default {
  data() {
    return {
      locationDialogVisible: false, // dialog控制器
      locationList: [], // 物流信息数据
    }
  },
  methods: {
    openLocationDialog() { // 开启dialog
      this.locationDataRequest();
      this.locationDialogVisible = true;
    },
    async locationDataRequest() { // 物流信息请求
      const {meta, data} = await locationData();
      if (meta.status !== 200) {
        console.log(meta);
        return this.$message.error(meta.msg);
      }
      return this.locationList = data;
    }
  },
  created() {
    this.$bus.$on('openLocationDialog', this.openLocationDialog);
  },
  destroyed() {
    this.$bus.$off('openLocationDialog');
  },
  components: {
    OrderTimeLine
  }
}
</script>

<style lang="scss" scoped>
</style>